package com.mm.scheme.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.mm.common.domain.po.Result;
import com.mm.scheme.domian.po.Scheme;
import com.mm.scheme.service.SchemeServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


/**
 * @BelongsProject: chatgpt-java-develop
 * @BelongsPackage: com.unfbx.controller
 * @Author : 游在海里的鱼
 * @CreateTime : 2024-03-20  20:12
 * @Version : 1.0
 * @ClassName :  方案控制器
 * @Description : TODO
 */
@Slf4j
@RestController
@Api(tags = "导图相关接口")
@RequestMapping("/scheme")
@RequiredArgsConstructor
public class SchemeController {
    private final SchemeServiceImpl schemeService;
    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 新增方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
     **/
    @ApiOperation("新增方案")
    @PostMapping("/addScheme")
    public Result addScheme(){
        return schemeService.addScheme();
    }
    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 编辑方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
    **/
    @ApiOperation("编辑方案")
    @PostMapping("/editScheme")
    public Result editScheme(Scheme scheme){
        return schemeService.editScheme(scheme);
    }

    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 删除方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
    **/
    @ApiOperation("删除方案")
    @GetMapping("/deleteScheme")
    public Result deleteScheme(@RequestParam("id")Long id){
        return schemeService.deleteScheme(id);
    }

    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 获取此用户的所有方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
    **/
    @ApiOperation("获取所有方案")
    @GetMapping("/getAllScheme")
    public Result getAllScheme(){
        return schemeService.getAllScheme();
    }

    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 获取此用户的方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
     **/
    @ApiOperation("获取方案")
    @GetMapping("/getScheme")
    public Result getScheme(@RequestParam("schemeId")Long schemeId){
        return schemeService.getScheme(schemeId);
    }

    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 获取方案的输入参数
     * @Describe: TODO
     * @modifier: [public] [实例方法]
    **/
    @ApiOperation("获取方案输入")
    @GetMapping("/getInput")
    public Result getInput(@RequestParam("schemeId") Long schemeId){
        return schemeService.getInput(schemeId);
    }

    /** ---------------------------------------------------------------------------------------------------------------------
     * @Method  : 使用方案
     * @Describe: TODO
     * @modifier: [public] [实例方法]
    **/
    @ApiOperation("使用方案")
    @GetMapping("/useScheme")
    public Result useScheme(@RequestParam("map")String map
            ,@RequestParam("schemeId")Long schemeId) throws JsonProcessingException {
        return schemeService.useScheme(map,schemeId);
    }

}
